#pragma once
#include "glut.h"

class ChessboardSurrogate
{
protected:
	int _columnsCount;
	int _rowsCount;
	int _cellWidth;

public:

	ChessboardSurrogate(int columnsCount, int rowsCount, int cellWidth) :
	  _columnsCount(columnsCount),
      _rowsCount(rowsCount),
	  _cellWidth(cellWidth)
	{
	}


	void Draw(int cx, int cy)
	{		
		//glTranslatef( -cx, -cy, 0);

		bool oddRow = true;
		for (int j = 0; j < _rowsCount; j++)
		{
			for (int i = 0; i < _columnsCount; i++)
			{
				bool f = ((i + 1) % 2);
				if ((oddRow && f) || (!oddRow && !f))
					continue;

				int x = i*_cellWidth;
				int y = j*_cellWidth;

				glBegin(GL_QUADS);
					glVertex3d( x, y, 0.0);
					glVertex3d( x + _cellWidth, y, 0.0);
					glVertex3d( x + _cellWidth, y + _cellWidth, 0.0);
					glVertex3d( x, y + _cellWidth, 0.0);
				glEnd();
			}
			oddRow = !oddRow;
		}
	}
};